﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyCompany.MyProject.IService;
using MyCompany.MyProject.Model.Logs;

namespace MyCompany.MyProject.WebApi.Controllers
{
    /// <summary>
    /// 日志控制器
    /// </summary>
    public class LogsController : BasePermissionApiController
    {
        private readonly IWebHostEnvironment _env;
        private readonly IBaseService<AuditSqlLog> _auditLog;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="env"></param>
        /// <param name="auditLog"></param>
        public LogsController(IWebHostEnvironment env,IBaseService<AuditSqlLog> auditLog)
        {
            _env = env;
            _auditLog = auditLog;
        }
        /// <summary>
        /// 获取日志文件内容
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [ProducesResponseType(StatusCodes.Status400BadRequest)]
        public async Task<IActionResult> GetSqlLog()
        {
            var res = await _auditLog.QuerySplit(d => d.DateTime <= DateTime.Now);
            return Ok(res);
        }


    }
}
